//package com.atmilan.quartz.config;
//
//import java.io.IOException;
//
//import org.quartz.Scheduler;
//import org.quartz.spi.JobFactory;
//import org.quartz.spi.TriggerFiredBundle;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.scheduling.quartz.AdaptableJobFactory;
//import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
//import org.springframework.scheduling.quartz.JobDetailFactoryBean;
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
//
//import com.atmilan.quartz.task.PushBrandTask;
//import com.atmilan.quartz.task.PushProductdTask;
//
///**
// * 调度器配置
// * @Description: 
// * @author daigb
// * @date 2021-12-30
// */
//@Configuration
//public class QuartzConfiguration {
//
//	@Autowired
//	private AutowireCapableBeanFactory capableBeanFactory;
//
//	/**
//	 * 初始化实例并交给IOC管理
//	 * @return
//	 */
//	@Bean
//	public JobFactory jobFactory() {
//		return new AdaptableJobFactory() {
//			@Override
//			protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
//				Object jobInstance = super.createJobInstance(bundle);
//				capableBeanFactory.autowireBean(jobInstance);
//				return jobInstance;
//			}
//		};
//	}
//
//	/************** start job **********************/
//	/**
//	 * 推送品牌数据到crmeb，每天凌晨3点
//	 * @return
//	 */
//	// ProductPushTask.pushBrand
//	@Bean
//	public JobDetailFactoryBean pushBrandHiku() {
//		JobDetailFactoryBean bean = new JobDetailFactoryBean();
//		bean.setJobClass(PushBrandTask.class);
//		bean.setDurability(true);
//		bean.setName("pushBrandHiku");
//		bean.setGroup("hikuGroup");
//		return bean;
//	}
//	@Bean
//	public CronTriggerFactoryBean cronTriggerFactoryBeanBrandHiku() {
//		CronTriggerFactoryBean bean = new CronTriggerFactoryBean();
//		bean.setJobDetail(pushBrandHiku().getObject());
//		bean.setCronExpression("0 0 3 * * ? ");
////		bean.setCronExpression("0/4 * * * * ? *");
//		bean.setName("cronTriggerFactoryBeanBrandHiku");
//		bean.setGroup("hikuGroup");
//		return bean;
//	}
//	
//	// ProductPushTask.pushProduct
//	@Bean
//	public JobDetailFactoryBean pushProductHiku() {
//	    JobDetailFactoryBean bean = new JobDetailFactoryBean();
//	    bean.setJobClass(PushProductdTask.class);
//	    bean.setDurability(true);
//	    bean.setName("pushProductHiku");
//	    bean.setGroup("hikuGroup");
//	    return bean;
//	}
//	@Bean
//	public CronTriggerFactoryBean cronTriggerFactoryBeanProductHiku() {
//	    CronTriggerFactoryBean bean = new CronTriggerFactoryBean();
//	    bean.setJobDetail(pushProductHiku().getObject());
//	    bean.setCronExpression("0 0 18 * * ?");
//	    bean.setName("cronTriggerFactoryBeanProductHiku");
//	    bean.setGroup("hikuGroup");
//	    return bean;
//	}
//	
//    /************** end job **********************/
//
//	@Bean
//	public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
//		SchedulerFactoryBean bean = new SchedulerFactoryBean();
//		bean.setJobFactory(jobFactory());
//		// 延迟启动
//		bean.setStartupDelay(1);
//		bean.setConfigLocation(new ClassPathResource("/quartz.properties"));
//		bean.setTriggers(cronTriggerFactoryBeanBrandHiku().getObject(), cronTriggerFactoryBeanProductHiku().getObject());
//		return bean;
//	}
//
//	/**
//	 * 获得Scheduler 对象
//	 * @return
//	 */
//	@Bean
//	public Scheduler scheduler() throws IOException {
//		return schedulerFactoryBean().getScheduler();
//	}
//
//}